package com.heima.wemedia.controller.v1;

import com.heima.model.admin.dtos.AdChannel;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/channel")
public class WmchannelController {
    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult findALl() {
        return wmChannelService.findALl();
    }
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel channel){
        return wmChannelService.saveChannel(channel);
    }
    @PostMapping("/list")
    public ResponseResult findListWithPage(@RequestBody ChannelDto dto){
        return wmChannelService.findListWithPage(dto);
    }
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody AdChannel adChannel){
        return wmChannelService.updateChannel(adChannel);
    }
    @GetMapping("/del/{id}")
    public ResponseResult delChannelById(@PathVariable("id") Integer id){
        return wmChannelService.delChannelById(id);
    }

}
